#include "lua.h"

#include <iostream>

namespace kxlua {

Lua::Lua() {
    state_ = luaL_newstate();
    luaL_openlibs(state_);
}

Lua::~Lua() {
    if (state_) {
        lua_close(state_);
        state_ = NULL;
    }
}

lua_State* Lua::GetState() {
    return state_;
}

const std::string Lua::GetLastError() const {
    return error_;
}

int Lua::DoFile(std::string name) {
    if (luaL_dofile(state_, name.data())) {
        error_ = lua_tostring(state_, -1);
    }
}

int Lua::DoString(std::string name) {

}

}
